package com.paireach.szwolaiyun.mode;

import android.text.TextUtils;

import org.json.JSONObject;

/**
 * Created by Administrator on 2016/6/23.
 */
public class UserMode {
    private String message="";//例如没有此用户之类的信息提醒
    private String companyPhone="";//异常电话
    private String appBackupPointTime="";//返点时间间隔
    private String name="";//用户名
    private boolean resultFlag=false;//用户登录请求成功标识


    public boolean getResultFlag(){
        return resultFlag;
    }
    public void setResultFlag(boolean resultFlag) {
        this.resultFlag = resultFlag;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getCompanyPhone() {
        return companyPhone;
    }

    public void setCompanyPhone(String companyPhone) {
        this.companyPhone = companyPhone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAppBackupPointTime() {
        return appBackupPointTime;
    }

    public void setAppBackupPointTime(String appBackupPointTime) {
        this.appBackupPointTime = appBackupPointTime;
    }

    public void init(String  jsonStr){
        try {
            JSONObject jsonObject=new JSONObject(jsonStr);
            setMessage(jsonObject.optString("message"));
            setResultFlag(jsonObject.optBoolean("resultFlag"));
            if(resultFlag){
                if(!TextUtils.isEmpty(jsonObject.optString("responseEntity"))&&!"null".equals(jsonObject.optString("responseEntity"))){
                    JSONObject userInfo=new JSONObject(jsonObject.optString("responseEntity"));
                    setName(userInfo.optString("name"));
                    setAppBackupPointTime(userInfo.optString("appBackupPointTime"));
                    setCompanyPhone(userInfo.optString("companyPhone"));
                }
            }


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void initFake(){
        try {
            setMessage("");
            setResultFlag(true);
            setName("test");
            setAppBackupPointTime("");
            setCompanyPhone("18100000001");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
